#pragma once
#include "prefab.h"
#include <vector>
#define GetResourceManager()	ResourceManager::GetInstance()

class ResourceManager
{
protected:
	ResourceManager () {}
	~ResourceManager () 
	{
		for (std::vector<Prefab*>::iterator it=m_prebab.begin(); it!=m_prebab.end();)
		{
			delete (*it);
			it = m_prebab.erase(it);
		}
	}

	/*implicit methods exist for the copy constructor and operator= and we want to forbid calling them.*/
	ResourceManager (const ResourceManager &){} 
	ResourceManager& operator = (const ResourceManager &) {}

public:
	static void CreateInstance ()
    {
        if ( ms_pInstance == NULL )
		   ms_pInstance = new ResourceManager();
    }
	static ResourceManager * GetInstance () 
    {
	   return ms_pInstance;
    }
	static void DestroyInstance () 
    {
	   if ( ms_pInstance )
	   {
		 delete ms_pInstance;
		 ms_pInstance = NULL;
	   }
    }

	void Init (const char* path);
	int GetRandomPrefab ();
	Prefab * GetPrefab (int id);

protected:
	static ResourceManager * ms_pInstance;
	std::vector<Prefab*> m_prebab;
};